package com.ubanger.util;

import android.app.Activity;
import android.widget.Toast;

/**
 * Created by Steven on 2017/3/3 0003.
 */

public abstract class UbangToast {
    private static Toast sToast;
    private static Activity sActivity;
    private static CharSequence sCharSequence;
    private static Runnable sRunnable = new Runnable() {
        @Override
        public void run() {
            if (null == sToast) {
                sToast = Toast.makeText(sActivity, "", Toast.LENGTH_SHORT);
            }
            sToast.setText(sCharSequence);
            sToast.show();
        }
    };

    public static void showToast(Activity activity, CharSequence content) {
        if (null != activity) {
            sActivity = activity;
            sCharSequence = content;
            activity.runOnUiThread(sRunnable);
        }
    }
}
